package com.foxit.pdf2html5.common.intergration;


import java.io.InputStream;

/**
 * @author shaojie_zhuo
 * @version 1.0
 * Cache storage interface.
 */
public interface ICacheStoreProvider {
	
	/**
	 * Add an new cache to cache store.
	 * This is a reserved interface, you do not need to implement this function right now, you can just return an
	 * UnsupportedOperationException.
	 * @param baseDoc source document object.
	 * @param description description of cache.
	 * @param inputStream an InputStream of cache data.
	 * @param pdfPassword password of PDF.
	 * @return return true if add cache successfully, otherwise return false.
	 * @throws CacheException 
	 * @see CacheException
	 * @see CacheDescription
	 */
	void addItemToCache(BaseDocument baseDoc,
			String description, InputStream inputStream,String pdfPassword) throws CacheException;

	/**
	 * Add an new cache to cache store.
	 * @param baseDoc source document object.
	 * @param description description of cache.
	 * @param inputString a String of cache data.
	 * @param pdfPassword password of PDF.
	 * @return return true if add cache successfully, otherwise return false.
	 * @throws CacheException 
	 * @see CacheException
	 * @see CacheDescription
	 */
	void addItemToCache(BaseDocument baseDoc, String description, String inputString,String pdfPassword) throws CacheException;

	
	/**
	 * Add an new cache to cache store.
	 * @param baseDoc source document object.
	 * @param description description of cache.
	 * @param inputData cache data.
	 * @param pdfPassword password of PDF.
	 * @return return true if add cache successfully, otherwise return false.
	 * @throws CacheException 
	 * @see CacheException
	 * @see CacheDescription
	 */
	void addItemToCache(BaseDocument baseDoc, String description, byte[] inputData,String pdfPassword) throws CacheException;
	
	/**
	 * Get a cache item, 
	 * @see BaseCacheItem
	 * @param baseDoc baseDoc source document object.
	 * @param description description of cache.
	 * @return return null if get cache item failed, otherwise return the cache item specified by description.
	 * @see CacheDescription
	 */
	BaseCacheItem getCachedItem(BaseDocument baseDoc, String description);
	
	/**
	 * Get an InputStream object by cache item to read cache data.
	 * @param cacheItem Cache item
	 * @param update whether to update last access date of the cache.
	 * return null if get cache stream failed, otherwise return a InputStream object to read cache data.
	 */
	InputStream getCachedStream(BaseCacheItem cacheItem,boolean update);
	
	/**
	 * Remove a specific document cache
	 * @param baseDoc
	 */
	void removeCache(BaseDocument baseDoc);
	
	/**
	 * Get password of PDF file.
	 * @param cacheItem Cache item
	 * @return return password of PDF file. return null if the record does not exist.
	 */
	String getPDFPassword(BaseCacheItem cacheItem);
}
